<template>
	<view class="body">
		<!-- 文本返回组件 -->
		<view style="position: fixed;">
			<return-text text="意见反馈"></return-text>
		</view>
		<view :style="{marginTop:headerTop +'px'}">
			<view class="textareaBox">
				<textarea class="feedback" :maxlength="150" v-model.trim="textContent" placeholder="描述你要反馈的内容，最多150个字。"
					:style="{height:textareaHeight + 'px'}" />
			</view>
			<view class="submit" @click="submitHandle">提交</view>
		</view>
	</view>
</template>

<script>
	import {
		capsuleTopHeight
	} from "../../mixins/mixins.js"
	export default {
		mixins: [capsuleTopHeight],
		data() {
			return {
				textareaHeight: 0,
				textContent: '',
				// 距离
				headerTop: 0
			};
		},
		created() {
			const wxWindowHeight = uni.getSystemInfoSync().windowHeight
			this.textareaHeight = wxWindowHeight - this.capsuleTop - this.capsuleHeight - 40 - 33 - 450
			this.headerTop = this.capsuleTop + this.capsuleHeight
		},
		methods: {
			async submitHandle() {
				if (!this.textContent) return uni.showToast({
					title: "请输入要反馈的内容",
					icon: "none"
				})
				const {
					data: result
				} = await uni.$http.post("/ym_server/IntactGoods/feedback", this.textContent)
				if (result.code === 200) {
					uni.showToast({
						title: "反馈成功，后续请留意消息界面。",
						icon: "none"
					})
					this.textContent = ""
				} else {
					uni.showToast({
						title: "反馈失败",
						icon: "none"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 整个大背景，最小高度为整个屏幕
	.body {
		width: 100%;
		min-height: 100vh;
		overflow: hidden;
		background: #eef2f4;
		
		// 输入框盒子
		.textareaBox{
			padding-top: 16upx;
			
			// 输入框
			.feedback {
				width: 100%;
				background: white;
				padding: 32upx;
				box-sizing: border-box;
				font-size: 32upx;
			}
		}
		
		// 提交按钮
		.submit {
			margin: 112upx 32upx 0upx 32upx;
			height: 80upx;
			background: #3FD3D1;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28upx;
			color: white;
		}
	}
</style>
